package com.ruibang.glass.material.controller;

import com.ruibang.glass.material.domain.req.AllocationManagementReq;
import com.ruibang.glass.material.domain.req.ycl.ManageOutBoundReq;
import com.ruibang.glass.material.domain.req.ycl.ManageOutInReq;
import com.ruibang.glass.material.entity.MaterialALLOutboundManagement;
import com.ruibang.glass.material.entity.MaterialAllocationManagement;
import com.ruibang.glass.material.service.GMaterialAllOutboundManagementService;
import com.ruibang.glass.material.service.MaterialAllocationManagementService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 调拨管理 前端控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */
@RestController

@RequestMapping("/api/material/allocation/management")
@Api(value = "调拨管理", tags = {"调拨管理"})
public class MaterialAllocationManagementController {



    @Autowired
    private MaterialAllocationManagementService materialAllocationManagementService;


    @PostMapping("/list")
    @ApiOperation(value = "出库申请管理列表", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody AllocationManagementReq allocationManagementReq) {
        return ResultBody.success(materialAllocationManagementService.getPage(allocationManagementReq));
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateById(@RequestBody MaterialAllocationManagement materialManagement) {
        materialAllocationManagementService.updateById(materialManagement);
        return ResultBody.success();
    }


    @PostMapping("/add")
    @ApiOperation(value = "新增调拨管理", response = ResultBody.class)
    public ResultBody addMaterialZPKOutboundManagement(@RequestBody MaterialAllocationManagement materialManagement) {
        materialAllocationManagementService.addMaterialAllocationManagement(materialManagement);
        return ResultBody.success();
    }

    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "详情查看", response = ResultBody.class)
    public ResultBody getOneById(@PathVariable("id") String id) {
        return ResultBody.success(materialAllocationManagementService.getMaterialAllocationManagement(id));
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getById(@PathVariable("id") String id) {
        return ResultBody.success(materialAllocationManagementService.getMaterialAllocationManagement(id));
    }


    @PostMapping("/deleteChoose")
    @ApiOperation(value = "选中删除", response = ResultBody.class)
    public ResultBody deleteChoose(@RequestBody MaterialAllocationManagement materialManagement) {
        materialAllocationManagementService.removeBatchByIds(materialManagement.getIds());
        return ResultBody.success();
    }


    @PostMapping("/updateItemHouse")
    @ApiOperation(value = "库存计算", response = ResultBody.class)
    public ResultBody updateItemHouse(@RequestBody MaterialAllocationManagement materialManagement) {
        materialAllocationManagementService.updateItemHouse(materialManagement);
        return ResultBody.success();
    }




}
